<script setup lang="ts">
import '../assets/css/common.css';

const props = withDefaults(defineProps<{
  title?: string
  moreTitle?: string
  showMore?: boolean
}>(), {
  title: '',
  moreTitle: '更多',
  showMore: false
})
const emit = defineEmits<{
  (e: 'toMore'): void
}>()
const toMore = () => {
  emit('toMore')
}
</script>

<template>
  <div class="card">
    <div class="flex-between flex-x-center">
      <div class="title" v-if="title">{{ title }}</div>
      <div v-if="showMore" class="more" @click="toMore">
        <span>{{ moreTitle }}</span>
        <i class="iconfont icon-arrow-right"></i>
      </div>
      <div v-else class="right">
        <slot name="right"></slot>
      </div>
    </div>

    <div class="content">
      <slot></slot>
    </div>
  </div>
</template>

<style scoped>
.card{
  background: #ffffff;
  border-radius: 10px;
  padding: 27px 26px;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}
.card .title {
  font-weight: bold;
  font-size: 20px;
  color: #000000;
}
.card .more {
  font-size: 14px;
  color: #8f8f8f;
  cursor: pointer;
}
</style>
